<?php
include("../conf.php");

class SqlHelper
{
	private $conn;	
	public function __construct()
	{			
		$this->conn = mysql_connect(Config::$server, Config::$user, Config::$psw);		
		mysql_select_db(Config::$db, $this->conn);	
	}
	
	public function __destruct()
	{		
		mysql_close($this->conn);
	} 
	
	public function ExecuteNonQuery($q){
		mysql_query($q);		
	}
	
	public function ExecuteQuery($q, $para){		
		$result = mysql_query($q, $this->conn);
		if (!$result) {
			
			return "";
			
		}
		$paras = explode("-",$para );		
		$i=0;			
		while ($row = mysql_fetch_assoc($result)) {
			$j=0;
			while($j < count($paras))
			{
				$t[$i][$paras[$j]]= $row[$paras[$j]];					
				$j++;
			}
			$i++;
			
			
		}
		mysql_free_result($result);
		if($i==0)
		return "";
		return json_encode($t);
	}
}
?>